/************************************************************
  函数目录：（在此写函数声明和简要注释）

 ************************************************************/
#define USER 100
#define PORT 8887
#include "func.h"

typedef struct task_s{
    int netFd;
    struct task_s *pNext;
}task_t;

typedef struct taskQueue_s{
    task_t *pFront;
    task_t *pRear;
    int queueSize;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}taskQueue_t;

typedef struct factory_s{
    pthread_t *tidArr;      // 线程池
    int threadNum;          // 线程池大小
    taskQueue_t taskQueue;  // 任务队列
    int runningFlag;        // 运行标志(用于线程池退出，该参数为0时表示已没有子线程正在运行，>
}factory_t;

typedef struct {     // 小火车，用于和客户端传送文件
    int length;         //文件大小
    char data[1000];         // 用于存放每次传输的数据
}train_t;

int clients_list[USER] = {0};
int clientSum = 0;
int exitPipe[2];


//func.h    function.h      
//function.c   mysql.c    passwd.c    serverFunction.c   tcp.c
//server  server.c    

/*
int factoryInit(factory_t *pFactory, int threadNum);

void sigFunc(int signum);
 
int taskEnQueue(taskQueue_t *pTaskQueue, int netFd);

int taskDeQueue(taskQueue_t *pTaskQueue);

int setnonblocking(int fd);

void addfd(int epollfd, int fd, bool enable_et);

char* substring(char* str, int start, int end);

void lsFunction(int clientfd);

void getsFunction(int clientfd,char* filename);

void mkdirFunction(int clientfd,char* buf);

void cdFunction(int clientfd);

void putsFunction(int clientfd);

void rmFunction(int clientfd, char *buf);

void pwdFunction(int clientfd);

void unknowFunction();

int sendBroadcastmessage(int clientfd);

int epollDel(int fd, int epfd);

int tcpInit(char *ip, char *port, int *pSockFd);

int transFile(int netFd);

int handleEvent(int netFd, factory_t *pFactory);

void cleanFunc(void *pArgs);

void* threadFunc(void *pArgs);
void makeWorker(factory_t *pFactory);

//新增加的接口
*/

//备选，数据库使用
//void putsFunction(int clientfd, char *filename, int epollfd,MYSQL * conn,char *username);
//void getsFunction(int clientfd, char *filename, int epollfd,MYSQL * conn,char *username);

void putsFunction(int clientfd, char *filename, int epollfd);
void getsFunction(int clientfd, char *filename, int epollfd);
void putsFunction_smallfile(int clientfd,int filefd,off_t filesize);
void getsFunction_smallfile(int clientfd,int filefd,off_t filesize);
void putsFunction_bigfile(int clientfd,int filefd,off_t filesize,off_t filexistmark);
void getsFunction_bigfile(int clientfd,int filefd,off_t filesize,off_t filexistmark);



